package cn.ncupyh.comptest;

//数组相关函数操作
public class Arrays {
    public static void main(String[] args) {
        int[] arr1 = {4,3,2,1};
        int[] arr2 = new int[5];
        java.util.Arrays.fill(arr2,2);
        System.out.println("arr1的toString:"+java.util.Arrays.toString(arr1));
        System.out.println("arr2的fill:"+ java.util.Arrays.toString(arr2));
        java.util.Arrays.sort(arr1);
        System.out.println("arr1的sort:"+java.util.Arrays.toString(arr1));
        arr2 = java.util.Arrays.copyOf(arr1, arr1.length+1);
        System.out.println("arr2:arr1的拷贝copyOf:"+java.util.Arrays.toString(arr2));
        System.arraycopy(arr1,0,arr2,0,arr1.length);
        System.out.println("arr2:arr1的拷贝arraycopy"+java.util.Arrays.toString(arr2));
        System.out.println("arr1和arr2的equals:"+java.util.Arrays.equals(arr1,arr2));
        int[] arr3 = {7,8,9};
        arr2 = arr3.clone();
        System.out.println(java.util.Arrays.toString(arr2));
    }
}
